this.BX=this.BX||{};(function(t,i,e,s){"use strict";var a,r,l,n,h,o,d,c,v;var f=function(){function t(){var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);this.offsetCache=0;this.target=i.target||null;this.content=i.content||null;this.responsive=i.responsive||null;this.autoPlaySpeed=i.autoPlaySpeed||1e3;this.autoPlay=i.autoPlay||false;this.dots=i.dots||false;this.dotsClass=i.dotsClass||"--default";this.arrows=i.arrows||false;this.arrowsClass=i.arrowsClass||"--default";this.vertical=i.vertical||false;this.infinite=i.infinite||false;this.carouselContainer=null;this.wrapper=null;this.track=null;this.nodeDots=null;this.nodeArrows=null;this.arrayDotsItem=[];this.arrayItems=[];this.arrayItemsWidth=0;this.arrayItemsHeight=0;this.isLastSlide=0;this.arrayArrowsItem=[];this.slidActive=1;this.sliderInterval=null;this.sliderAllCount=this.content.length;this.defaultSettings()}babelHelpers.createClass(t,[{key:"defaultSettings",value:function t(){this.defaultParameters={};for(var i in this){this.defaultParameters[i]=this[i]}}},{key:"getItem",value:function t(e,s){var r=this.slidActive-1===s?"--active":"";var l=i.Tag.render(a||(a=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__slide ','">\n\t\t\t\t',"\n\t\t\t</div>\n\t\t"])),r,e.html);i.Event.bind(l,"mouseenter",this.stopSlide.bind(this));i.Event.bind(l,"mouseleave",this.runSlide.bind(this));if(this.arrayItems.indexOf(e)===-1){this.arrayItems.push(l)}return l}},{key:"setTrackCharacteristics",value:function t(){if(this.arrayItemsWidth===0&&this.arrayItemsHeight===0){for(var i=0;i<this.arrayItems.length;i++){this.arrayItemsWidth+=this.arrayItems[i].offsetWidth;this.arrayItemsHeight+=this.arrayItems[i].offsetHeight}}}},{key:"initSlider",value:function t(){this.runSlide()}},{key:"stopSlide",value:function t(){clearInterval(this.sliderInterval)}},{key:"changeActivePoint",value:function t(){if(this.arrayDotsItem.length>1){for(var i=0;i<this.arrayDotsItem.length;i++){if(this.arrayDotsItem[i].classList.contains("--active")){this.arrayDotsItem[i].classList.remove("--active")}}this.arrayDotsItem[this.slidActive-1].classList.add("--active")}}},{key:"changeActiveSlide",value:function t(){if(this.arrayItems.length>1){for(var i=0;i<this.arrayItems.length;i++){if(this.arrayItems[i].classList.contains("--active")){this.arrayItems[i].classList.remove("--active")}}this.arrayItems[this.slidActive-1].classList.add("--active")}}},{key:"changeActiveArrow",value:function t(i){if(!this.infinite){this.arrayArrowsItem.map((function(t){t.classList.remove("--disabled")}));if(this.slidActive===this.sliderAllCount||i>=this.isLastSlide&&this.isLastSlide>0){this.arrayArrowsItem[this.arrayArrowsItem.length-1].classList.add("--disabled")}else if(this.slidActive===1){this.arrayArrowsItem[0].classList.add("--disabled")}}}},{key:"changeActive",value:function t(i){this.changeActivePoint();this.changeActiveSlide();if(!this.infinite){this.changeActiveArrow(i)}}},{key:"runSlide",value:function t(){var i=this;if(this.sliderAllCount>1&&this.autoPlay){this.trackOffsetStep();this.sliderInterval=setInterval((function(){var t=i.slidActive+1>i.sliderAllCount?1:i.slidActive+1;i.showSlide(t)}),this.autoPlaySpeed)}}},{key:"trackOffsetStep",value:function t(){if(this.offsetCache===0){this.offsetCache=this.wrapper?this.wrapper.offsetWidth:0}return this.offsetCache}},{key:"getTrackShift",value:function t(i){var e=0;if(i>1){var s=0;if(i>=this.isLastSlide&&this.isLastSlide>0){s=this.isLastSlide-1}else{s=i-1}if(this.vertical){var a=this.arrayItemsHeight;for(var r=0;r<s;r++){a-=this.arrayItems[r].offsetHeight;if(a<this.wrapper.offsetHeight){this.isLastSlide=i;e+=a+this.arrayItems[r].offsetHeight-this.wrapper.offsetHeight}else{e+=this.arrayItems[r].offsetHeight}}}else{var l=this.arrayItemsWidth;for(var n=0;n<s;n++){l-=this.arrayItems[n].offsetWidth;if(l<this.wrapper.offsetWidth){this.isLastSlide=i;e+=l+this.arrayItems[n].offsetWidth-this.wrapper.offsetWidth}else{e+=this.arrayItems[n].offsetWidth}}}}return e}},{key:"showSlide",value:function t(i){this.setTrackCharacteristics();if(i>0&&i<=this.sliderAllCount){this.slidActive=i;if(this.track){if(this.vertical){this.track.style.transform="translateY("+-this.getTrackShift(i)+"px)"}else{this.track.style.transform="translateX("+-this.getTrackShift(i)+"px)"}}}clearInterval(this.sliderInterval);this.runSlide();this.changeActive(i)}},{key:"nextSlide",value:function t(){if(this.infinite){if(this.slidActive===this.sliderAllCount){this.slidActive=1;this.showSlide(this.slidActive)}else if(this.slidActive<this.sliderAllCount){this.slidActive+=1;this.showSlide(this.slidActive)}}else{if(this.slidActive<this.sliderAllCount){this.slidActive+=1;this.showSlide(this.slidActive)}}}},{key:"prevSlide",value:function t(){if(this.infinite){if(this.slidActive===1){this.slidActive=this.sliderAllCount;this.showSlide(this.slidActive)}else if(this.slidActive>1){this.slidActive-=1;this.showSlide(this.slidActive)}}else{if(this.slidActive>1){this.slidActive-=1;this.showSlide(this.slidActive)}}}},{key:"getArrows",value:function t(){var e=this.vertical?"--vertical":"";this.nodeArrows=i.Tag.render(r||(r=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__arrows--container ','"></div>\n\t\t'])),e);var s=this.infinite?"":"--disabled";var a=i.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__arrow '," --prev "," ",'"></div>\n\t\t'])),this.arrowsClass,s,e);var h=i.Tag.render(n||(n=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__arrow '," --next ",'"></div>\n\t\t'])),this.arrowsClass,e);i.Event.bind(a,"click",this.prevSlide.bind(this));i.Event.bind(h,"click",this.nextSlide.bind(this));this.arrayArrowsItem.push(a);this.arrayArrowsItem.push(h);this.nodeArrows.append(a);this.nodeArrows.append(h);return this.nodeArrows}},{key:"getDots",value:function t(){this.nodeDots=i.Tag.render(h||(h=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__dots ','"></div>\n\t\t'])),this.dotsClass);for(var e=0;e<this.sliderAllCount;e++){var s=this.slidActive===e+1?"--active":"";var a=i.Tag.render(o||(o=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-carousel__dots--item '," ",'">\n\t\t\t\t</div>\n\t\t\t'])),this.dotsClass,s);i.Event.bind(a,"click",this.showSlide.bind(this,e+1));this.arrayDotsItem.push(a);this.nodeDots.append(a)}return this.nodeDots}},{key:"getCarouselContent",value:function t(){var e=this;var s=this.vertical?"--vertical":"";this.track=i.Tag.render(d||(d=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__track ','"></div>\n\t\t'])),s);this.content.map((function(t,i){e.track.appendChild(e.getItem(t,i))}));this.wrapper=i.Tag.render(c||(c=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__wrapper">\n\t\t\t\t',"\n\t\t\t</div>\n\t\t"])),this.track);this.carouselContainer=i.Tag.render(v||(v=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-carousel__container ui-carousel__scope ','">\n\t\t\t\t',"\n\t\t\t</div>\n\t\t"])),s,this.wrapper);if(this.dots&&this.sliderAllCount>1){this.carouselContainer.appendChild(this.getDots())}if(this.arrows&&this.sliderAllCount>1){this.carouselContainer.appendChild(this.getArrows())}return this.carouselContainer}},{key:"responsiveCarousel",value:function t(){if(this.responsive){for(var i=0;i<this.responsive.length;i++){if(window.innerWidth>this.responsive[0].breakpoint){var e=this.defaultParameters;for(var s in e){this[s]=e[s]}break}else if(window.innerWidth<=this.responsive[i].breakpoint){var a=this.responsive[i].settings;for(var r in a){this[r]=a[r]}}}}}},{key:"carouselResize",value:function t(){var i=this;if(this.responsive){window.addEventListener("resize",(function(){for(var t=0;t<i.responsive.length;t++){if(i.windowWidth>i.responsive[t].breakpoint&&window.innerWidth<i.responsive[t].breakpoint){i.windowWidth=window.innerWidth;i.init()}else if(i.windowWidth<i.responsive[t].breakpoint&&window.innerWidth>i.responsive[t].breakpoint){i.windowWidth=window.innerWidth;i.init()}}}))}}},{key:"init",value:function t(){if(this.target&&this.content){this.windowWidth=window.innerWidth;i.Dom.clean(this.target);this.responsiveCarousel();this.target.appendChild(this.getCarouselContent());this.initSlider();this.carouselResize()}}}]);return t}();t.Carousel=f})(this.BX.UI=this.BX.UI||{},BX,BX.Event,BX);
//# sourceMappingURL=bundle.map.js